home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / acpi / lid.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2009-10-13  |  1KB  |  49 lines

  1. #!/bin/bash
  2. # TODO:  Change the above to /bin/sh
  3.  
  4. test -f /usr/share/acpi-support/state-funcs || exit 0
  5.  
  6. . /usr/share/acpi-support/power-funcs
  7. . /usr/share/acpi-support/policy-funcs
  8. . /etc/default/acpi-support
  9.  
  10. [ -x /etc/acpi/local/lid.sh.pre ] && /etc/acpi/local/lid.sh.pre
  11.  
  12. if [ `CheckPolicy` = 0 ]; then exit; fi
  13.  
  14. grep -q closed /proc/acpi/button/lid/*/state
  15. if [ $? = 0 ]
  16. then
  17.     for x in /tmp/.X11-unix/*; do
  18.     displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
  19.     getXuser;
  20.     if [ x"$XAUTHORITY" != x"" ]; then
  21.         export DISPLAY=":$displaynum"        
  22.         . /usr/share/acpi-support/screenblank
  23.     fi
  24.     done
  25. else
  26.     for x in /tmp/.X11-unix/*; do
  27.     displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
  28.     getXuser;
  29.     if [ x"$XAUTHORITY" != x"" ]; then
  30.         export DISPLAY=":$displaynum"
  31.         grep -q off-line /proc/acpi/ac_adapter/*/state
  32.         if [ $? = 1 ]
  33.         then
  34.         if pidof xscreensaver > /dev/null; then 
  35.             su $user -c "xscreensaver-command -unthrottle"
  36.         fi
  37.         fi
  38.         if [ x$RADEON_LIGHT = xtrue ]; then
  39.         [ -x /usr/sbin/radeontool ] && radeontool light on
  40.         fi
  41.         if [ `pidof xscreensaver` ]; then
  42.         su $user -c "xscreensaver-command -deactivate"
  43.         fi
  44.         su $user -c "xset dpms force on"
  45.     fi
  46.     done
  47. fi
  48. [ -x /etc/acpi/local/lid.sh.post ] && /etc/acpi/local/lid.sh.post
  49.